<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Flex</title>
  <style>
    * {
      box-sizing: border-box;
    }

    body {
      display: flex;
      box-sizing: border-box;
      padding-bottom: 100px;
      margin: 0;
    }

    .container {
      width: 50%;
      padding: 32px;
    }

    .box {
      display: flex;
      gap: 16px;
      width: 600px;
      height: 100px;
      /* outline: 1px solid black; */
      padding: 16px;
      border-radius: 8px;
      margin-bottom: 32px;
      background-color: beige;
      overflow: hidden;
      resize: both;
    }

    .item {
      background-color: coral;
      border-radius: 8px;
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 32px;
      font-family: Arial, Helvetica, sans-serif;
      color: #fff;
    }

    @media (max-width: 1280px) {
      .container1 {
        display: none;
      }

      .container2 {
        width: 100vw;
      }
    }
  </style>
</head>

<body>
  <div class="container container1">
    <h2>Flex布局</h2>
    <div class="box box1">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
      <div class="item item3">3</div>
      <div class="item item4">4</div>
      <div class="item item5">5</div>
    </div>

    <h2>垂直居中对齐</h2>
    <div class="box box1-1">
      <div class="item item1">1</div>
    </div>
    <style>
      .box1-1 {
        justify-content: center;
        align-items: center;
        height: 300px;
      }

      .box1-1 .item1 {
        width: 100px;
        height: 100px;
        flex: none;
      }
    </style>

    <h2>指定显示大小</h2>
    <div class="box box2">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
      <div class="item item3">3</div>
    </div>
    <style>
      .box2 .item2 {
        flex: 0 0 100px;
      }

      .box2 .item3 {
        flex: 3;
      }
    </style>

    <h2>固定大小&使用margin控制排版1</h2>
    <div class="box box3">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
    </div>
    <style>
      .box3 .item {
        width: 100px;
        flex: none;
      }

      .box3 .item2 {
        margin-left: auto;
      }
    </style>

    <h2>固定大小&使用margin控制排版2</h2>
    <div class="box box4">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
      <div class="item item3">3</div>
    </div>
    <style>
      .box4 .item {
        width: 100px;
        flex: none;
      }

      .box4 .item2 {
        margin-left: auto;
      }
    </style>

    <h2>换行和整体对齐</h2>
    <div class="box box5">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
      <div class="item item3">3</div>
      <div class="item item4">4</div>
      <div class="item item5">5</div>
      <div class="item item6">6</div>
      <div class="item item7">7</div>
      <div class="item item8">8</div>
      <div class="item item9">9</div>
      <div class="item item10">10</div>
      <div class="item item11">11</div>
    </div>
    <style>
      .box5 {
        flex-flow: row wrap;
        height: auto;
        resize: both;
        align-content: flex-end;
        /* justify-content: center; */
      }

      .box5 .item {
        width: 100px;
        height: 50px;
        flex: none;
      }
    </style>

    <h2>单独设置项目对齐</h2>
    <div class="box box6">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
      <div class="item item3">3</div>
      <div class="item item4">4</div>
      <div class="item item5">5</div>
    </div>
    <style>
      .box6 {
        resize: vertical;
        height: 200px;
      }

      .box6 .item1 {
        align-self: flex-start;
      }

      .box6 .item2 {
        align-self: flex-end;
      }

      .box6 .item3 {
        align-self: center;
      }

      .box6 .item4 {
        align-self: stretch;
      }

      .box6 .item5 {
        align-self: baseline;
      }
    </style>

    <h2>按列显示</h2>
    <div class="box box6-1">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
      <div class="item item3">3</div>
    </div>
    <style>
      .box6-1 {
        height: 400px;
        width: 300px;
        flex-direction: column;
        align-items: center;
        resize: vertical;
      }

      .box6-1 .item {
        width: 100px;
        height: 100px;
        flex: none
      }
    </style>
  </div>
  <div class="container container2" style="background-color: #ebebeb;">
    <h2>两栏布局</h2>
    <div class="box box7">
      <div class="item item1">Sider</div>
      <div class="item item2">Main</div>
    </div>
    <style>
      .box7 {
        height: 400px;
      }

      .box7 .item1 {
        flex: 0 0 160px;
      }

      .box7 .item2 {
        flex: 1;
      }
    </style>

    <h2>三栏布局</h2>
    <div class="box box8">
      <div class="item item1">Header</div>
      <div class="item item2">Body</div>
      <div class="item item3">Footer</div>
    </div>
    <style>
      .box8 {
        flex-direction: column;
        height: 500px;
        resize: vertical;
      }

      .box8 .item1 {
        flex: 0 0 100px;
      }

      .box8 .item2 {
        flex: 1;
      }

      .box8 .item3 {
        flex: 0 0 60px;
      }
    </style>

    <h2>中台布局</h2>
    <div class="box box9">
      <div class="item item1">Header</div>
      <div class="item item2">
        <div class="subitem subitem1">Left</div>
        <div class="subitem subitem2">Main</div>
        <div class="subitem subitem3">Right</div>
      </div>
      <div class="item item3">Footer</div>
    </div>
    <style>
      .box9 {
        flex-direction: column;
        height: 500px;
        resize: both;
      }

      .box9 .item1 {
        flex: 0 0 100px;
      }

      .box9 .item2 {
        background-color: transparent;
        flex: 1;
        display: flex;
        gap: 8px
      }

      .box9 .item2 .subitem {
        background-color: rgb(239, 110, 36);
        flex: 1;
        height: 100%;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .box9 .item2 .subitem1 {
        flex: 0 0 160px;
      }

      .box9 .item2 .subitem3 {
        flex: 0 0 100px;
      }

      .box9 .item3 {
        flex: 0 0 60px;
      }
    </style>
  </div>
</body>

</html>